import { Controller, Get, Post, Param, Body, Query, Headers } from '@nestjs/common';
import { SlideService } from './slide.service';
import { AddSlideDto, GetSlidePageDto, SlideOnOffDto } from './slide.dto';


@Controller('admin/slide')
export class SlideController {
  constructor(private readonly slideService: SlideService) { }

  @Post('addOrUpdate')
  addOrUpdate(@Body() addSlideDto: AddSlideDto, @Headers('state') state) {
    const { username } = state
    return this.slideService.addOrUpdate(addSlideDto, username)
  }

  @Post('page')
  getSlidePage(@Body() getSlidePageDto: GetSlidePageDto) {
    return this.slideService.getSlidePage(getSlidePageDto)
  }

  @Post('slideOnOff/:id/:status')
  slideOnOff(@Param() slideOnOffDto: SlideOnOffDto) {
    return this.slideService.slideOnOff(slideOnOffDto)
  }

  @Post('delete/:id')
  deleteSlide(@Param('id') id: string) {
    return this.slideService.deleteSlide(+id)
  }

  @Get('get')
  getSlideInfo(@Query('id') id: string) {
    return this.slideService.getSlideInfo(+id)
  }

  @Post('validateCode/:code')
  slideValidateCode(@Param('code') code: string) {
    return this.slideService.slideValidateCode(code)
  }
}
